home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / cqa.zip / CANTASN.TCP < prev    next >
Text File  |  1991-04-01  |  854b  |  19 lines

  1. QUESTION:  I keep getting the error "cannot assign 'void near *' to
  2.            'int near *'" when I try to compile my C++ program.  What am
  3.            I doing wrong?
  4.  
  5. ANSWER:    As AT&T defines C++ you cannot assigne a void pointer to a
  6.            pointer of another type without casting.  This differs from
  7.            ANSI C.  In ANSI C it is acceptable to assign a void pointer
  8.            to a pointer of another type.  In C++ it is required to cast
  9.            the pointer. For example:
  10.  
  11. /* ANSI C  */                           /* AT&T 2.0 C++ */
  12.  
  13. #include <alloc.h>                      #include <alloc.h>
  14.  
  15. void main(void) {                       void main(void) {
  16.     char *foo;                              char *foo;
  17.     foo = malloc(10);                       foo = (char *) malloc(10);
  18. }                                       }
  19.